let pageSize = 3;
let curentpage = 1;

function render() {
  $.ajax({
    type: 'GET',
    url: '/user/queryUser',
    data: {
      pageSize,
      page:curentpage,
    },
    dataType: 'json',
    success: function (res) {
      console.log(res)

      $("tbody").html(template("tmp", res))
      paginator(res.total)
    }
  })

}
render()
var id = ''
var isDelete = ''
$('tbody').on('click', '.btn', function () {
  //console.log(111);
  id = $(this).parent().attr('data-id')
  isDelete = $(this).hasClass('btn-danger') ? '0' : '1'
  console.log(isDelete);
console.log(id);

})
//console.log(id);
$('.btn-ok').click(function () {
  $.ajax({
    type: 'post',
    url: '/user/updateUser',
    data: {
      id: id,
      isDelete: isDelete,
    },
    dataType: 'json',
    success: function (res) {
      console.log(res)
      render()
      $('.modal').modal('hide')
    }
  })

})
function paginator(total) {
  $("#paginator").bootstrapPaginator({
  bootstrapMajorVersion:3,//默认是2，如果是bootstrap3版本，这个参数必填
  currentPage:curentpage,//当前页
  totalPages:Math.ceil(total/pageSize),//总页数
  
  onPageClicked:function(event, originalEvent, type,page){
    //为按钮绑定点击事件 page:当前点击的按钮值
    curentpage = page
    render()
  }
});
}
